home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / obsolete / set_viewport.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  74 lines

  1. ; $Id: set_viewport.pro,v 1.2 1997/01/15 04:02:19 ali Exp $
  2. ;
  3. ; Copyright (c) 1989-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. pro set_viewport, xmin, xmax, ymin, ymax
  7. ;+
  8. ; NAME:
  9. ;    SET_VIEWPORT
  10. ;
  11. ; PURPOSE:
  12. ;    Emulate the Version I, VMS/IDL SET_VIEWPORT procedure.
  13. ;    Sets the default position and size of the plot data window.
  14. ;
  15. ; CATEGORY:
  16. ;    Plotting.
  17. ;
  18. ; CALLING SEQUENCE:
  19. ;    SET_VIEWPORT, Xmin, Xmax [, Ymin, Ymax]
  20. ;
  21. ; INPUTS:
  22. ;    Xmin:    Minimum X normalized coordinate of the plotting data window.
  23. ;    Xmax:    Maximum X normalized coordinate of the plotting data window.
  24. ;
  25. ; OPTIONAL INPUT PARAMETERS:
  26. ;    Ymin:    Minimum Y normalized coordinate of the plotting data window.
  27. ;
  28. ;    Ymax:    Maximum Y normalized coordinate of the plotting data window.
  29. ;
  30. ; KEYWORD PARAMETERS:
  31. ;    None.
  32. ;
  33. ; OUTPUTS:
  34. ;    No explicit outputs.
  35. ;
  36. ; COMMON BLOCKS:
  37. ;    None.
  38. ;
  39. ; SIDE EFFECTS:
  40. ;    Sets !P.POSITION.
  41. ;
  42. ; RESTRICTIONS:
  43. ;    None.
  44. ;
  45. ; PROCEDURE:
  46. ;    Straightforward.  !P.POSITION is directly set.
  47. ;
  48. ; MODIFICATION HISTORY:
  49. ;    DMS, June, 1989.
  50. ;
  51. ;    Modified, April, 1991 to restore defaults if called with no
  52. ;             parameters.
  53. ;-
  54. on_error,2              ;Return to caller if an error occurs
  55. n = n_params()
  56. if n_elements(xmin) eq 0 then xmin = 0.
  57. if n_elements(xmax) eq 0 then xmax = 0.
  58.  
  59. IF xmin eq xmax then begin    ;Set defaults?
  60.     !x.margin = [10,3]
  61.     !y.margin = [4,2]
  62.     !p.position = 0
  63.     return
  64.     ENDIF
  65.  
  66. IF n le 2 then begin    ;Calculate Ymin and Ymax
  67.     y = !x.margin * !d.x_ch_size / !d.x_size ;Margins in normalized coords
  68.     ymin = y(0)
  69.     ymax = 1.0 - y(1)
  70.     ENDIF
  71. !p.position = [ xmin, ymin, xmax, ymax] ;Set it
  72. end
  73.